<template>
<<<<<<< HEAD
  <div class="container">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="账号">
        <el-input v-model="form.studentNumber"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input
          v-model="form.password"
          @keyup.enter.native="onSubmit"
          type="password"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">登录</el-button>
        <!-- <el-button>注册</el-button> -->
      </el-form-item>
    </el-form>
  </div>
=======
  <el-form ref="form" :model="form" label-width="80px">
    <el-form-item label="账号">
      <el-input v-model="form.studentNumber"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input
        v-model="form.password"
        @keyup.enter.native="onSubmit"
        type="password"
      ></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">立即创建</el-button>
      <el-button>注册</el-button>
    </el-form-item>
  </el-form>
>>>>>>> c90ca6f6edfb84fe54655fa82bb244498a7f6cd7
</template>

<script>
export default {
  data() {
    return {
      form: {
        studentNumber: "",
        password: "",
      },
    };
  },
  methods: {
    onSubmit() {
      this.$axios
        .post("/login", {
          studentNumber: this.form.studentNumber,
          password: this.form.password,
        })
        .then((res) => {
          const jwt = res.headers["authorization"];
          // console.log(res);
          this.$store.commit("set_token", jwt);
          this.$notify({
            title: "成功",
            message: "登录成功",
            type: "success",
            duration: 2000,
          });
          setTimeout(() => {
            this.$router.push("index");
          }, 1000);
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.el-input {
  width: 250px;
}
.container {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  transform: translateX(-5%);
}
</style>